
.text
	.align 4
	.global begin
	.type begin, function

begin:
    b reset_handler
    b undefied_handler
    b swi_handler
    b prefetch_handler
    b abort_handler
    nop
    b irq_handler
    b fiq_handler

/* all begins here */
reset_handler:

/* into SYS mode */
    mrs r0, cpsr                     @cpsr->r0
    bic r0, r0, #0x1f                @clear the last five bits of r0
    orr r0, r0, #0x1f                @set the last five bits of r0"11111"
    msr cpsr_c,r0                    @r0->cpsr
    mov r0, #0x01
    mov r1, #0x02
    mov r2, #0x03
    mov r3, #0x04
    mov r4, #0x05
    mov r5, #0x06
    mov r6, #0x07
    mov r7, #0x08
    mov r8, #0x09
    mov r9, #0x0a
    mov r10, #0x0b
    mov r11, #0x0c
    mov r12, #0x0d
    mov r13, #0x0e
    mov r14, #0x0f

/* into FIQ mode */
    mrs r0, cpsr                     @cpsr->r0
    bic r0, r0, #0x1f                @clear the last five bits of r0
    orr r0, r0, #0x11                @set the last five bits of r0"10001"
    msr cpsr_c,r0                    @r0->cpsr
    mov r8,  #0x10
    mov r9,  #0x11
    mov r10, #0x12
    mov r11, #0x13
    mov r12, #0x14
    mov r13, #0x15
    mov r14, #0x16

/* into SVC mode */
    mrs r0, cpsr                     @cpsr->r0
    bic r0, r0, #0x1f                @clear the last five bits of r0
    orr r0, r0, #0x13                @set the last five bits of r0"10011"
    msr cpsr_c,r0                    @r0->cpsr
    mov r13, #0x17
    mov r14, #0x18

/* into Abort mode */
    mrs r0, cpsr                     @cpsr->r0
    bic r0, r0, #0x1f                @clear the last five bits of r0
    orr r0, r0, #0x17                @set the last five bits of r0"10111"
    msr cpsr_c,r0                    @r0->cpsr
    mov r13, #0x19
    mov r14, #0x1a

/* into IrQ mode */
    mrs r0, cpsr                     @cpsr->r0
    bic r0, r0, #0x1f                @clear the last five bits of r0
    orr r0, r0, #0x12                @set the last five bits of r0"10010"
    msr cpsr_c,r0                    @r0->cpsr
    mov r13, #0x1b
    mov r14, #0x1c

/* into UNDEF mode */
    mrs r0, cpsr                     @cpsr->r0
    bic r0, r0, #0x1f                @clear the last five bits of r0
    orr r0, r0, #0x1b                @set the last five bits of r0"11011"
    msr cpsr_c,r0                    @r0->cpsr
    mov r13, #0x1d
    mov r14, #0x1e

undefied_handler:
    b undefied_handler
swi_handler:
    b swi_handler
prefetch_handler:
    b prefetch_handler
abort_handler:
    b abort_handler
irq_handler:
    b irq_handler
fiq_handler:
    b fiq_handler

.data
	.align  4

